# -*- coding: utf-8 -*-
"""
 @Time    : 2021/2/1 下午4:04
 @Author  : tgy
 
"""
from abc import ABC, abstractmethod


class Processor(ABC):

    def __init__(self, read, write):
        self.read = read
        self.write = write

    def processor(self):
        ...
        while True:
            data = self.read.readline()
            if not data:
                break
            action_data = self.action(data)
            self.write.write(action_data)

    @abstractmethod
    def action(self, data):
        # assert False, 'current method can not run'
        ...

class SupProcessor(Processor):

    def __init__(self, read, write):
        super().__init__(read, write)

    def action(self, data):
        return data.upper()


def test01():
    ...
    import sys
    f = open('./delegate.py', mode='rt', encoding='utf-8')
    sub_processor = SupProcessor(f, sys.stdout)
    sub_processor.processor()
    f.close()


if __name__ == '__main__':
    ...
    test01()
